package com.study.testSpringBoot.testReflection;

import java.lang.reflect.Field;

import com.study.testSpringBoot.interceptor.vo.User;

public class testReflection {

	
	public static boolean verificationParam(Object obj){
		//获取对象中的属性
		Field[] fields = obj.getClass().getDeclaredFields();
		if(fields != null && fields.length > 0) {
			for(Field f : fields) {
				//取消访问检查
				f.setAccessible(true);
				//获取属性名
				String name = f.getName();
				System.out.println(name);
				//获取属性值
				Object object;
				try {
					object = f.get(obj);
					System.out.println(object);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return true;
	}
	
	
	public static void main(String[] args){
		User user = new User(1, "wuyu");
		verificationParam(user);
	}
}
